package com.locatead.test.resources;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.locatead.test.model.SimpleModel;
import com.locatead.test.services.SimpleService;

@Path("/test")
@Component
public class SimpleResource {
	
	@Autowired
	private SimpleService service;
	
	@GET
	@Path("/echo/{test}")
	@Produces("text/plain")
	public String showMessage(
			@Context UriInfo uri,
			@PathParam("test") String test) {
		return "[" + uri.toString() + "] " + service.attachStar(test);
	}
	
	@POST
	@Path("/simple/{id}/{num}")
	@Produces({"Application/XML", "Application/JSON"})
	public String createSimpleMode(
			@Context UriInfo uri,
			@PathParam("id") String id,
			@PathParam("num") int num) {
		service.createSimpleModel(new SimpleModel(id, num));
		return "OK";
	}
}
